package com.example.uniquekey;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author shishaopeng
 * Date: 2023-10-09-15-40
 * Desc:
 */
@RestController
@RequestMapping("/test")
public class UniqueKeyController {

    @Resource
    UniqueKeyGenerator uniqueKeyGenerator;


    @GetMapping("get")
    public Object get() {
        long financeReceiptRecordSn = uniqueKeyGenerator.generate("finance_receipt_record_sn");
        System.out.println(financeReceiptRecordSn);
        return financeReceiptRecordSn;
    }

    @GetMapping("get/customer")
    public Object getCustomer() {
        GeneralKeyGenerator financeReceiptRecordSn = uniqueKeyGenerator.getCustomerKeyGenerator("finance_receipt_record_sn", 1);
        long id = financeReceiptRecordSn.nextKey();
        System.out.println(id);
        return id;
    }
}
